package com.learn.thread;

public class TestLamabda {
    /**
     * 2 静态内部类
     */
    static class MyInterfaceImpl2 implements MyInterface {
        @Override
        public void show() {
            System.out.println("show(2)");
        }
    }

    public static void main(String[] args) {
        MyInterface myInterface = new MyInterfaceImpl();
        myInterface.show();

        myInterface = new MyInterfaceImpl2();
        myInterface.show();

        /**
         * 局部内部类
         */
        class MyInterfaceImpl3 implements MyInterface {
            @Override
            public void show() {
                System.out.println("show(3)");
            }
        }
        myInterface = new MyInterfaceImpl3();
        myInterface.show();
        /**
         * 匿名内部类
         */
        myInterface = new MyInterfaceImpl() {
            @Override
            public void show() {
                System.out.println("show(4)");
            }
        };

        myInterface.show();
        /**
         * Lambda表达式
         */

        myInterface = () -> {
            System.out.println("show(4)");
        };
        myInterface.show();

        myInterface = () -> System.out.println("show(5)");
        myInterface.show();
    }

}

/**
 * 定义函数式接口
 */
interface MyInterface {
    public void show();
}

/**
 * 1.函数式接口的实现类
 */
class MyInterfaceImpl implements MyInterface {
    @Override
    public void show() {
        System.out.println("show(1)");
    }
}
